<?php
/**
 * 个人积累信息类
 * @author zhanghui
 * @create_date 2008-02-29
 */
class BabyScore{
	function __construct(){}
	function __destruct(){}
	
	/**
	 * 初始化个人积累信息
	 * @param :$conn 数据库连接类
     * @param  array $arr_input - baby_id,visit_cnt,vitality_cnt,fame_cnt,charm_cnt,warm_cnt
     */
	function initBabyScore($conn,$arr_input){
		$str_query = "insert into";
		$str_query .= " baby_info";
		$str_query .= " set";
		$str_query .= " baby_id={$arr_input['baby_id']}";
		
		$conn->executeQuery($str_query);
	}
	
	/**
	 *  更新个人积累信息
	 * @param :$conn 数据库连接类
     * @param  array $arr_input - baby_id,visit_cnt,vitality_cnt,fame_cnt,charm_cnt,warm_cnt
     */
	/* 增加访问量 */
	function increaseVisitScore($conn,$arr_input){
		$str_query = "update";
		$str_query .= " baby_info";
		$str_query .= " set";
        $str_query .= " and visit_cnt=visit_cnt+1";
		$arr_input .= " where";
		$arr_input .= " baby_id={$arr_input['baby_id']}";
		
		$conn->executeQuery($str_query);
	}
	
	/* 更新生命力 */
	function increaseVitalityScore($conn,$arr_input){
		$str_query = "update";
		$str_query .= " baby_info";
		$str_query .= " set";
        $str_query .= " and vitality_cnt=vitality_cnt+1";
		$arr_input .= " where";
		$arr_input .= " baby_id={$arr_input['baby_id']}";
		
		$conn->executeQuery($str_query);
	}
	
	/* 更新名望 */
	function increaseFameScore($conn,$arr_input){
		$str_query = "update";
		$str_query .= " baby_info";
		$str_query .= " set";
        $str_query .= " and fame_cnt=fame_cnt+1";
		$arr_input .= " where";
		$arr_input .= " baby_id={$arr_input['baby_id']}";
		
		$conn->executeQuery($str_query);
	}
	
	/* 更新魅力 */
	function increaseCharmScore($conn,$arr_input){
		$str_query = "update";
		$str_query .= " baby_info";
		$str_query .= " set";
        $str_query .= " and charm_cnt=charm_cnt+1";
		$arr_input .= " where";
		$arr_input .= " baby_id={$arr_input['baby_id']}";
		
		$conn->executeQuery($str_query);
	}
	
	/* 更新热情 */
	function increaseWarmScore($conn,$arr_input){
		$str_query = "update";
		$str_query .= " baby_info";
		$str_query .= " set";
        $str_query .= " and warm_cnt=warm_cnt+1";
		$arr_input .= " where";
		$arr_input .= " baby_id={$arr_input['baby_id']}";
		
		$conn->executeQuery($str_query);
	}
	
	/**
	 *  获取个人积累信息
	 * @param :$conn 数据库连接类
     * @param  array $arr_input - baby_id,visit_cnt,vitality_cnt,fame_cnt,charm_cnt,warm_cnt
     * @param string $limit 
     * @return : $arr_output
     *			  baby_id, 			    [0]<br>
     *			  visit_cnt, 		    [1]<br>
     *			  vitality_cnt, 		[2]<br>
     *			  fame_cnt, 		    [3]<br>
     *			  charm_cnt, 		    [4]<br>
     *			  warm_cnt, 		    [5]<br>
     */
	function getBabyScoreList($conn,$arr_input,$limit = null){
		$str_query = "select";
		$str_query .= " baby_id";
		$str_query .= ",visit_cnt";
		$str_query .= ",vitality_cnt";
		$str_query .= ",fame_cnt";
		$str_query .= ",charm_cnt";
		$str_query .= ",warm_cnt";
		$str_query .= " from";
		$str_query .= " baby_info";
		$str_query .= " where";
		$str_query .= " baby_id={$arr_input['baby_id']}";
		
		$arr_output = $conn->selectQuery($str_query);
		return $arr_output;
	}
}
?>